<div class="form">
    <?php
    /** @var RepVinculacionController $this */
    /** @var RepVinculacion $model */
    /** @var AweActiveForm $form */
    $form = $this->beginWidget('ext.AweCrud.components.AweActiveForm', array(
        'id' => 'rep-vinculacion-form',
        'enableAjaxValidation' => false,
        'clientOptions' => array('validateOnSubmit' => true, 'validateOnChange' => false,),
        'enableClientValidation' => true,
    ));
    Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/protected/modules/vinculacion/assets/repVinculacion/_form.js', CClientScript::POS_END);
    ?>

    <p class="note">
        <?php echo Yii::t('AweCrud.app', 'Fields with') ?> <span class="required">*</span>
        <?php echo Yii::t('AweCrud.app', 'are required') ?>.    </p>

    <?php echo $form->errorSummary($model) ?>

    <?php
//    echo $form->dropDownListRow($model, 'id_ficha', CHtml::listData(Ficha::model()->findAll(), 'id', Ficha::representingColumn())) 
    $this->widget('zii.widgets.jui.CJuiAutoComplete', array(
//        'name' => 'ajaxrequest',
        'model' => $model,
        'attribute' => 'cedula',
        // additional javascript options for the autocomplete plugin
        'source' => $this->createUrl("repTrabajoCampo/listaCedulas"),
        'htmlOptions' => array(
            'style' => 'height:20px;',
            'class' => 'span5',
            'placeholder' => 'NUMERO DE CEDULA',
            'maxlength' => 10,
        ),
        'options' => array(
            'minLength' => '3',
            'showAnim' => 'fold',
            'select' => 'js:function(event, ui){            
                horas(ui.item.value);
            }',
            'search' => 'js:function( event, ui ) { 
                horas($("#RepVinculacion_cedula").val());   
            }',
        ),
    ));
    ?>
    <?php echo $form->textFieldRow($model, 'actividades', array('class' => 'span5', 'maxlength' => 500)) ?>
    <?php echo $form->textFieldRow($model, 'descripcion', array('class' => 'span5', 'maxlength' => 500)) ?>
    <?php echo $form->dropDownListRow($model, 'id_empresa', CHtml::listData(Empresa::model()->findAll(), 'id', Empresa::representingColumn())) ?>

    <label for="RepEventosybanquetes_fechas" class="required">Periodo <span class="required">*</span></label>
    <?php
    $this->widget('ext.bootstrap.widgets.TbDateRangePicker', array(
        'model' => $model,
        'attribute' => 'fechas',
        'options' => array(
            'format' => 'YYYY/MM/DD',
        ),
        'htmlOptions' => array(
            'readonly' => true
        ),
    ));
    ?>
    <?php
    if (!empty($model->cedula)) {
        $ficha = Ficha::model()->cedulaaid($model->cedula);
        if (!empty($ficha)) {
            //encontrar todos los trabajos de campos q ha realizado
            $horasCumplidas = $model->horasCumplidas($ficha);
            //totales horas de aqel id de area
            $totalHorasAreasegunID = 200;
            echo $listhoras = '<div> Total: ' . $totalHorasAreasegunID . '</div>'
            . '<div> Cumplidas: ' . $horasCumplidas . '</div>'
            . '<div> Por cumplir: ' . ($totalHorasAreasegunID - $horasCumplidas) . '</div>';
        }
    }
    ?>
    <div id="idHoras">
    </div>
<?php echo $form->textFieldRow($model, 'n_horas', array('class' => 'span5')) ?>
    <?php echo $form->dropDownListRow($model, 'nivel', RepTrabajoCampo::model()->NivelesOptions, array('empty' => '- Seleccione -')) ?>
    <?php echo $form->textFieldRow($model, 'res_obtenido', array('class' => 'span5', 'maxlength' => 200)) ?>
    <?php echo $form->textFieldRow($model, 'res_esperado', array('class' => 'span5', 'maxlength' => 200)) ?>
    <div class="form-actions">
    <?php
    $this->widget('bootstrap.widgets.TbButton', array(
        'buttonType' => 'submit',
        'type' => 'primary',
        'label' => $model->isNewRecord ? Yii::t('AweCrud.app', 'Create') : Yii::t('AweCrud.app', 'Save'),
    ));
    ?>
        <?php
        $this->widget('bootstrap.widgets.TbButton', array(
            //'buttonType'=>'submit',
            'label' => Yii::t('AweCrud.app', 'Cancel'),
            'htmlOptions' => array('onclick' => 'javascript:history.go(-1)')
        ));
        ?>
    </div>

<?php $this->endWidget(); ?>
</div>